# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.14.1 FATAL_ERROR)
project(libabckit)

file(GLOB libabckit_sources
    "src/abckit_impl.cpp" ,
    "src/helpers_common.cpp" ,
    "src/ir_impl.cpp" ,
    "src/ir_interface_impl.cpp" ,
    "src/isa_dynamic_impl.cpp" ,
    "src/isa_dynamic_impl_instr_1.cpp" ,
    "src/isa_dynamic_impl_instr_2.cpp" ,
    "src/isa_static_impl.cpp" ,
    "src/metadata_arkts_inspect_impl.cpp" ,
    "src/metadata_arkts_modify_impl.cpp" ,
    "src/metadata_inspect_impl.cpp" ,
    "src/metadata_js_inspect_impl.cpp" ,
    "src/metadata_js_modify_impl.cpp" ,
    "src/metadata_modify_impl.cpp" ,
    "src/metadata_unknown_inspect_impl.cpp" ,
    "src/statuses_impl.cpp"
)

file(GLOB abckit_adapter_dynamic_source_set
    "src/adapter_dynamic/abckit_dynamic.cpp" ,
    "src/adapter_dynamic/convert.cpp" ,
    "src/adapter_dynamic/helpers_dynamic.cpp" ,
    "src/adapter_dynamic/metadata_inspect_dynamic.cpp" ,
    "src/adapter_dynamic/metadata_modify_dynamic.cpp" ,
)

file(GLOB abckit_adapter_dynamic_source_set
    "src/adapter_dynamic/abckit_dynamic.cpp" ,
    "src/adapter_dynamic/convert.cpp" ,
    "src/adapter_dynamic/helpers_dynamic.cpp" ,
    "src/adapter_dynamic/metadata_inspect_dynamic.cpp" ,
    "src/adapter_dynamic/metadata_modify_dynamic.cpp" ,
)

file(GLOB abckit_adapter_static_source_set
    "src/adapter_static/abckit_static.cpp" ,
    "src/adapter_static/name_util.cpp" ,
    "src/adapter_static/helpers_static.cpp" ,
    "src/adapter_static/inst_modifier.cpp" ,
    "src/adapter_static/ir_static.cpp" ,
    "src/adapter_static/ir_static_instr_1.cpp" ,
    "src/adapter_static/metadata_inspect_static.cpp" ,
    "src/adapter_static/metadata_modify_static.cpp" ,
    "src/adapter_static/modify_name_helper.cpp" ,
    "src/adapter_static/runtime_adapter_static.cpp" ,
    "src/adapter_static/string_util.cpp" ,
)

file(GLOB abckit_codegen_static_source_set
    "src/codegen/codegen_static.cpp" ,
)

file(GLOB abckit_ir_builder_dynamic_source_set
    "src/irbuilder_dynamic/inst_builder_dyn.cpp" ,
    "src/irbuilder_dynamic/ir_builder_dyn.cpp" ,
)

file(GLOB abckit_mem_manager_source_set
    "src/mem_manager/mem_manager.cpp" ,
)

file(GLOB libabckit_graph_wrapper_source_set
    "src/wrappers/graph_wrapper/graph_wrapper.cpp" ,
)

file(GLOB abckit_pandasm_wrapper_source_set
    "src/wrappers/pandasm_wrapper.cpp" ,
)

set(ark_root "${CMAKE_CURRENT_SOURCE_DIR}/../")

include_directories(${ark_root})
include_directories(${ark_root}/libabckit/include)
include_directories(${ark_root}/libabckit/src)
include_directories(${ark_root}/libabckit)

include_directories(${ark_root}/assembler)
include_directories(${ark_root}/libpandabase)
include_directories(${ark_root}/libpandafile)

include_directories(${ark_root}/static_core)
include_directories(${ark_root}/static_core/assembler)
include_directories(${ark_root}/static_core/compiler)
include_directories(${ark_root}/static_core/bytecode_optimizer)
include_directories(${ark_root}/static_core/libarkfile)
include_directories(${ark_root}/static_core/libpandabase)

set(OUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../out)
include_directories(${OUT_DIR}/x64.debug/gen/arkcompiler/runtime_core/static_core/assembler)

add_library(${PROJECT_NAME} SHARED
            ${libabckit_sources}
            ${abckit_adapter_dynamic_source_set}
            ${abckit_adapter_dynamic_source_set}
            ${abckit_adapter_static_source_set}
            ${abckit_codegen_static_source_set}
            ${abckit_ir_builder_dynamic_source_set}
            ${abckit_mem_manager_source_set}
            ${libabckit_graph_wrapper_source_set}
            ${abckit_pandasm_wrapper_source_set}
        ../ark_guard/ark_guard/main.cpp
        ../ark_guard/library/ark_guard.cpp
        ../ark_guard/include/ark_guard/ark_guard.h
        tests/ut/metadata_core/inspect_api/annotations/annotations_static_test.cpp
)



